/**
 * 文件描述如下：
 * 1. 处理交通流量参数页面的数据
 */

const data_top_2 = [
  { id: 0, key: 'online-load-data', parentNode: null, name: '在线运行', showType: 'switch', inputType: 'switch' },
  { id: 1, key: 'save-source-data', parentNode: null, name: '保存原始数据', showType: 'switch', inputType: 'switch' },
  { id: 2, key: 'save-source-nums', parentNode: null, name: '保存最近原始数据的帧数', showType: 'input', inputType: 'uint' },
  { id: 3, key: 'save-b3-result', parentNode: null, name: '保存B3结果', showType: 'switch', inputType: 'switch' },
  { id: 4, key: 'save-b4-result', parentNode: null, name: '保存B4结果', showType: 'switch', inputType: 'switch' },
  { id: 5, key: 'save-b5-result', parentNode: null, name: '保存B5结果', showType: 'switch', inputType: 'switch' },
  { id: 5, key: 'pre-functionality', parentNode: null, name: '开启数据预处理部分', showType: 'switch', inputType: 'switch' },
]

// 处理交通流量页面的数据
const data_1 = {
  title: 'b3事件',
  data: [
    { id: 0, key: 'queue-length', parentNode: 'b3-functionality', name: '排队长度', showType: 'switch', inputType: 'switch' },
    { id: 1, key: 'lane-flow', parentNode: 'b3-functionality', name: '车流量', showType: 'switch', inputType: 'switch' },
    { id: 2, key: 'space-headway', parentNode: 'b3-functionality', name: '车头间距', showType: 'switch', inputType: 'switch' },
    { id: 3, key: 'time-headway', parentNode: 'b3-functionality', name: '车头时距', showType: 'switch', inputType: 'switch' },
    { id: 4, key: 'mean-speed', parentNode: 'b3-functionality', name: '平均速度', showType: 'switch', inputType: 'switch' },
    { id: 5, key: 'pedestrians-sensing', parentNode: 'b3-functionality', name: '行人感应', showType: 'switch', inputType: 'switch' },
    { id: 6, key: 'overflow', parentNode: 'b3-functionality', name: '溢出', showType: 'switch', inputType: 'switch' },
    { id: 7, key: 'deadlock', parentNode: 'b3-functionality', name: '死鎖', showType: 'switch', inputType: 'switch' },
    { id: 8, key: 'phase-empty', parentNode: 'b3-functionality', name: '相位空放', showType: 'switch', inputType: 'switch' },
    { id: 9, key: 'space-occupancy', parentNode: 'b3-functionality', name: '空间占有率', showType: 'switch', inputType: 'switch' },
    { id: 10, key: 'queue-waiting-time', parentNode: 'b3-functionality', name: '排队等待时长', showType: 'switch', inputType: 'switch' },
    { id: 11, key: 'congestion', parentNode: 'b3-functionality', name: '拥堵, 从b5接结果', showType: 'switch', inputType: 'switch' },
    { id: 12, key: 'class-queue-num', parentNode: 'b3-functionality', name: '拥堵, 从b5接结果', showType: 'switch', inputType: 'switch' },
    { id: 13, key: 'nonmotor-flow', parentNode: 'b3-functionality', name: '非机动车流量', showType: 'switch', inputType: 'switch' },
  ],
}

const data_2 = {
  title: 'b4事件',
  data: [
    { id: 0, key: 'lane-flow', parentNode: 'b4-functionality', name: '车流量', showType: 'switch', inputType: 'switch' },
    { id: 1, key: 'mean-delay', parentNode: 'b4-functionality', name: '延误', showType: 'switch', inputType: 'switch' },
    { id: 2, key: 'mean-stop-nums', parentNode: 'b4-functionality', name: '平均停车次数', showType: 'switch', inputType: 'switch' },
    { id: 3, key: 'queue-length-max', parentNode: 'b4-functionality', name: '最大排队长度', showType: 'switch', inputType: 'switch' },
    { id: 4, key: 'time-headway-section', parentNode: 'b4-functionality', name: '车头时距', showType: 'switch', inputType: 'switch' },
    { id: 5, key: 'time-occupancy', parentNode: 'b4-functionality', name: '时间占有率', showType: 'switch', inputType: 'switch' },
    { id: 6, key: 'space-headway', parentNode: 'b4-functionality', name: '车头间距', showType: 'switch', inputType: 'switch' },
    { id: 7, key: 'mean-speed', parentNode: 'b4-functionality', name: '平均速度', showType: 'switch', inputType: 'switch' },
    { id: 8, key: 'avg-lane-mean-v', parentNode: 'b4-functionality', name: '平均速度亦庄4.0', showType: 'switch', inputType: 'switch' },
    { id: 9, key: 'green-light-start-queue-length', parentNode: 'b4-functionality', name: '绿灯起亮排队长度', showType: 'switch', inputType: 'switch' },
    { id: 10, key: 'red-light-start-car-nums', parentNode: 'b4-functionality', name: '红灯起亮未通过车辆数', showType: 'switch', inputType: 'switch' },
    { id: 11, key: 'green-light-loss-time', parentNode: 'b4-functionality', name: '绿损时间', showType: 'switch', inputType: 'switch' },
  ],
}

const data_3 = {
  title: 'b5',
  data: [
    { id: 0, key: 'illegal-stop', parentNode: 'b5-functionality', name: '违停', showType: 'switch', inputType: 'switch' },
    { id: 1, key: 'motor-retrograde', parentNode: 'b5-functionality', name: '机动车逆行', showType: 'switch', inputType: 'switch' },
    { id: 2, key: 'nonmotor-retrograde', parentNode: 'b5-functionality', name: '非机动车逆行', showType: 'switch', inputType: 'switch' },
    { id: 3, key: 'motor-occupy-bus-lane', parentNode: 'b5-functionality', name: '机动车占用公交车道', showType: 'switch', inputType: 'switch' },
    { id: 4, key: 'motor-occupy-nonmotor-lane', parentNode: 'b5-functionality', name: '机动车占用非机动车道', showType: 'switch', inputType: 'switch' },
    { id: 5, key: 'nonmotor-parking-over-line', parentNode: 'b5-functionality', name: '非机动车越线停车', showType: 'switch', inputType: 'switch' },
    { id: 6, key: 'not-following-lane-guide', parentNode: 'b5-functionality', name: '机动车不按车道导向行驶', showType: 'switch', inputType: 'switch' },
    { id: 7, key: 'motor-over-speed', parentNode: 'b5-functionality', name: '机动车超速', showType: 'switch', inputType: 'switch' },
    { id: 8, key: 'motor-stroll', parentNode: 'b5-functionality', name: '机动车慢行', showType: 'switch', inputType: 'switch' },
    { id: 9, key: 'spill', parentNode: 'b5-functionality', name: '抛洒物', showType: 'switch', inputType: 'switch' },
    { id: 10, key: 'roadwork', parentNode: 'b5-functionality', name: '施工区', showType: 'switch', inputType: 'switch' },
    { id: 11, key: 'nonmotor-occupy-motor-lane', parentNode: 'b5-functionality', name: '非机动车占用机动车道', showType: 'switch', inputType: 'switch' },
    { id: 12, key: 'cars-accident', parentNode: 'b5-functionality', name: '车车事故', showType: 'switch', inputType: 'switch' },
    { id: 13, key: 'nonmotor-no-helmets', parentNode: 'b5-functionality', name: '非机动车不戴头盔', showType: 'switch', inputType: 'switch' },
    { id: 14, key: 'people-cars-accident', parentNode: 'b5-functionality', name: '人车事故', showType: 'switch', inputType: 'switch' },
    { id: 15, key: 'people-run-red-light', parentNode: 'b5-functionality', name: '行人闯红灯', showType: 'switch', inputType: 'switch' },
    { id: 16, key: 'nonmotor-run-red-light', parentNode: 'b5-functionality', name: '非机动车闯红灯', showType: 'switch', inputType: 'switch' },
    { id: 17, key: 'stop-driving', parentNode: 'b5-functionality', name: '停驶', showType: 'switch', inputType: 'switch' },
    { id: 18, key: 'congestion', parentNode: 'b5-functionality', name: '拥堵', showType: 'switch', inputType: 'switch' },
    { id: 19, key: 'cross-lane', parentNode: 'b5-functionality', name: '机动车压线', showType: 'switch', inputType: 'switch' },
    { id: 20, key: 'change-lane', parentNode: 'b5-functionality', name: '机动车违规换道', showType: 'switch', inputType: 'switch' },
    { id: 21, key: 'motor-run-red-light', parentNode: 'b5-functionality', name: '机动车闯红灯', showType: 'switch', inputType: 'switch' },
  ],
}

const data_4 = {
  title: '可视化',
  data: [
    { id: 0, key: 'ashow', parentNode: 'post-functionality', name: '本地可视化', showType: 'switch', inputType: 'switch' },
    { id: 1, key: 'ashow-web', parentNode: 'post-functionality', name: 'web可视化', showType: 'switch', inputType: 'switch' },
    { id: 2, key: 'post', parentNode: 'post-functionality', name: '后处理+数据结果转换+结果保存', showType: 'switch', inputType: 'switch' },
  ],
}

// 聚合数据
const data_main_2 = [data_1, data_2, data_3, data_4]
export const dataProcessingTransportation_2 = (params) => {
  if (!params) return
  // 头部的块
  data_top_2.forEach((item) => {
    item.value = item.parentNode ? params[item.parentNode][item.key] : params[item.key]
  })

  data_main_2.forEach((item) => {
    item.data.forEach((item2) => {
      item2.value = item2.parentNode ? params[item2.parentNode][item2.key] : params[item2.key]
    })
  })

  return { data_top_2, data_main_2 }
}
